#include "8-red_black_tree.hpp"

template<class T = int>
RbTree<T>* createRbTree()
{
  typedef RbNode<T> Node;
  Node* root = new Node(13);
  root->lchild = new Node(10);
  root->lchild->parent = root;
  root->rchild = new Node(15);
  root->rchild->parent = root;
  root->lchild->lchild = new Node(9);
  root->lchild->lchild->parent = root->lchild;
  root->rchild->lchild = new Node(14);
  root->rchild->lchild->parent = root->rchild;
  root->rchild->rchild = new Node(16);
  root->rchild->rchild->parent = root->rchild;
  root->rchild->rchild->lchild = new Node(17);
  root->rchild->rchild->lchild->parent = root->rchild->rchild;
  root->rchild->rchild->lchild->lchild = new Node(18);
  root->rchild->rchild->lchild->lchild->parent = root->rchild->rchild->lchild;
  return new RbTree<T>(root);
}

template<class T = int>
void testBaseRbTree(RbTree<T>* tree)
{
  tree->preOrder(); std::cout << std::endl;
  tree->inOrder(); std::cout << std::endl;
  tree->postOrder(); std::cout << std::endl;

  tree->levelOrder(); std::cout << std::endl;
}

int main (int argc, char* argv[])
{
  // auto tree = createRbTree();
  // testBaseRbTree(tree);
  // tree->print();

  int arr[] = {2,3,4,5,6,7,8,9,1,10,11,12};
  int len = sizeof(arr) / sizeof(arr[0]);

  RbTree<int> tree;
  for (int i = 0; i < len; ++i) {
    tree.insertNode(arr[i]);
    tree.print();
  }
  std::cout << tree.getHight() << std::endl;

  int data = 0;
  while (std::cin >> data) {
    tree.delNode(data);
    tree.print();
  }

  return 0;
}
